package Sort;

import java.util.Arrays;

public class TestSort {
    public static void main(String[] args) {
        //1.第一种
//        int[] a = {12,15,9,26,23,18};
//        Arrays.sort(a);//快速排序
//        System.out.println(Arrays.toString(a));//打印结果
        //2.第二种
         //2.1创建初始值
        int[] from = {1,2,3,4,5};

        int[]  to = Arrays.copyOf(from,5);
        System.out.println(Arrays.toString(to));//[1, 2, 3, 4, 5]
        //2.2复制
        int[] to2 = Arrays.copyOf(from,3);
        System.out.println(Arrays.toString(to2));//[1, 2, 3]
        //2.3扩容
        int[] to3 = Arrays.copyOf(from,10);//[1, 2, 3, 4, 5, 0, 0, 0, 0, 0]
        System.out.println(Arrays.toString(to3));
        //2.4截取个数"保头不保尾"******左闭右开。
        int[] to4 = Arrays.copyOfRange(from,2,4);//下标数保2不保4
        System.out.println(Arrays.toString(to4));//[3, 4]
    }

}
